function Install-RegistryKey
{
        [cmdletbinding(SupportsShouldProcess=$True)]
        Param( 
        [Parameter(Mandatory=$true,ValueFromPipeline=$true)] 
        [ValidateScript({Test-Path $_ -PathType Container})] 
        [String] 
        $ArchivePath,
        
        [Parameter(Mandatory=$true)] 
        [String] 
        $TargetRegistryKey
		        
        )
		
    Begin
    {
        $watch = [system.diagnostics.stopwatch]::StartNew() 
        write-verbose "Start Install-RegistryKey to $TargetRegistryKey from $ArchivePath"        
    }
    End
    {
        write-verbose "End Install-RegistryKey to $TargetRegistryKey from $ArchivePath"        
        $watch.Stop();
        Write-Verbose "Function duration : $($watch.Elapsed)"
    }
    Process
    {                
    
        #Find archive according to the path directory
        $archiveRegistry = Get-Item -Path $ArchivePath
        
        if ($archiveRegistry -eq $null)
        {
            throw New-Object System.Exception "NO Archive registry directory"
        }

		#Call msdeploy to synchronize package with destination
		$commandToExecute = '& "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:"{0}" -dest:"auto"'
		$sourceProvider=[System.String]::Format('archiveDir="""{0}"""',$archiveRegistry.FullName)        
		#$destinationProvider=[System.String]::Format('regKey="""{0}"""',$TargetRegistryKey)
        $commandToExecute = [System.String]::Format($commandToExecute, $sourceProvider, $destinationProvider)
		
		 #Add whatif support
		if($PSBoundParameters['Whatif'])
		{
			$commandToExecute += " -Whatif"
		}			
		Write-verbose "Command to execute : $commandToExecute"
		Invoke-Command -ScriptBlock ([scriptblock]::create($commandToExecute))
			        
    }
}
